﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDOS.Objects;
using Microsoft.Xna.Framework;

namespace DDOS.Game_State
{
    class Level0 : LevelLayer
    {
        Random ran = new Random();
        public Level0(Player plyr)
        {
            SoundManager.Instance.Play(SoundManager.Instance.InGame, true);
            base.curRoom = new Room();
            base.curRoom.InitializeComponents(plyr);
            base.nextRoom = null;
            Enemy0 e0 = new Enemy0();
            Enemy0 e1 = new Enemy0();
            e0.InitialCoordinates(500, 150);
            e1.InitialCoordinates(800, 300);
            e0.init_random(ran);
            e1.init_random(ran);
            e0.InitializeComponents();
            e1.InitializeComponents();
            e0.set_room(curRoom);
            e1.set_room(curRoom);
            base.curRoom.add_enemy(e0);
            base.curRoom.add_enemy(e1);
           


            Wall hw0 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(0, -200, 640, 50));
            Wall hw1 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(640, -200, 1280, 50));
            Wall hw2 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(0, 670, 640, 1200));
            Wall hw3 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(640, 670, 1280, 1200));

            Wall vw0 = new Wall(ImageManager2D.Instance.Wall_Vertical, new BoundingRectangle(0, 50, 150, 360));
            Wall vw1 = new Wall(ImageManager2D.Instance.Wall2_Vertical, new BoundingRectangle(0, 360, 150, 670));
            Wall vw2 = new Wall(ImageManager2D.Instance.Wall_Vertical, new BoundingRectangle(1130, 50, 1280, 360));
            Wall vw3 = new Wall(ImageManager2D.Instance.Wall_Vertical, new BoundingRectangle(1130, 360, 1280, 670));


            base.curRoom.add_wall(hw0);
            base.curRoom.add_wall(hw1);
            base.curRoom.add_wall(hw2);
            base.curRoom.add_wall(hw3);

            base.curRoom.add_wall(vw0);
            base.curRoom.add_wall(vw1);
            base.curRoom.add_wall(vw2);
            base.curRoom.add_wall(vw3);

            Room room = new Room();
            room.InitializeComponents(plyr);


            Wall hw4 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(0, -200, 640, 50));
            Wall hw5 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(640, -200, 1500, 50));
            Wall hw6 = new Wall(ImageManager2D.Instance.Wall, new BoundingRectangle(0, 670, 1500, 2000));

            Wall vw4 = new Wall(ImageManager2D.Instance.Wall_Vertical, new BoundingRectangle(-125, 50, 75, 670));
            Wall vw5 = new Wall(ImageManager2D.Instance.Wall2_Vertical, new BoundingRectangle(1200, 50, 1600, 670));

            room.add_wall(hw4);
            room.add_wall(hw5);
            room.add_wall(hw6);

            room.add_wall(vw4);
            room.add_wall(vw5);

          
            
            TransitionObject t = new TransitionObject(room,this,new BoundingCircle(900,600,50), new Vector2(800, 500),ImageManager2D.Instance.Hole,new Vector2(300,300),true);
      //      TransitionObject t2 = new TransitionObject(curRoom, this, new BoundingCircle(75, 75, 50), new Vector2(75, 75), ImageManager2D.Instance.Hole,new Vector2(400,400));

            base.curRoom.add_transition(t);
          //  room.add_transition(t2);

            Boss1 boss = new Boss1();
            boss.init_target(plyr);

            boss.InitialCoordinates(500, 500);
            boss.init_random(ran);
            boss.InitializeComponents();

            room.add_enemy(boss);

            base.curRoom.Activate();
           // room.Activate();
        }

        public Level0()
        {
            // TODO: Complete member initialization
        }

        public override void Draw()
        {
            ScreenManager.Instance.CurrentSpriteBatch.Draw(ImageManager2D.Instance.LevelBackground2,Vector2.Zero,Color.White);
            base.Draw();
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gt)
        {
            if (base.nextRoom != null)
                base.intransition = true;
            if (base.intransition && halfway)
            {
                base.curRoom = nextRoom;
                base.nextRoom = null;
                base.halfway = false;
            }
                 curRoom.Update(gt); 
            
            base.Update(gt);
        }
    }
}
